package per.ethan.javase.thread;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
 * @author Ethan
 * @date 2020/04/27 11:03
 */
public class WebDownload {

    public static void download(String url) {
        String name = "./images/" + FilenameUtils.getName(url);
        try {
            FileUtils.copyURLToFile(new URL(url), new File(name));
            System.out.println("下载成功：" + FilenameUtils.getName(url));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
